<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>版本信息编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>

<body style="background-color: white;">
<div class="layui-fluid" id="orderEdit">
    <form class="layui-form layui-form-pane" id="formsubmit" style="width: 500px;margin:20px auto"
          action="/after/zadan/editSave">
           <input type="hidden" id="id" name="id" value="${(agg.id?c)!''}">
            <div class="layui-form-item">
                <label class="layui-form-label">礼物名字</label>
                <div class="layui-input-inline layui-show-xs-block">
                    <select name="giftid" id="giftid">
                        <option value="">请选择</option>
                           <#list sort as so>
                              <option value="${(so.id?c)!''}" <#if agg.giftid==so.id>selected</#if>>${so.giftname!''}</option>
                           </#list>
                    </select>
                </div>
            </div>

<div class="layui-form-item">
    <label class="layui-form-label">一次礼物的概率</label>
    <div class="layui-input-inline">
        <input type="text" id="probe" name="probe"  value="${(agg.probe)!''}" required lay-verify="required"
               autocomplete="off" class="layui-input" />
    </div>
    <span>请输入1~1000</span>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">十次礼物的概率</label>
    <div class="layui-input-inline">
        <input type="text" id="probe2" name="probe2" value="${(agg.probe2)!''}"  required lay-verify="required"
               autocomplete="off" class="layui-input" />
    </div>
    <span>请输入1~1000</span>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">百次礼物的概率</label>
    <div class="layui-input-inline">
        <input type="text" id="probe3" name="probe3" value="${(agg.probe3)!''}"  required lay-verify="required"
               autocomplete="off" class="layui-input" />
    </div>
    <span>请输入1~1000</span>
</div>



<div class="layui-form-item">
    <label class="layui-form-label">奖池礼物数量</label>
    <div class="layui-input-inline">
        <input type="number" id="num" name="num" value="${(agg.num?c)!''}"  required lay-verify="required"
               autocomplete="off" class="layui-input" />
    </div>
</div>



        <div class="layui-form-item">
            <label class="layui-form-label">购买方式</label>
            <div class="layui-input-inline layui-show-xs-block">
                <select name="gametype" id="gametype">
                              <option <#if agg.gametype==2>selected</#if> value="2">金蛋</option>
                              <option <#if agg.gametype==3>selected</#if> value="3">钻石蛋</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save">&emsp;确认&emsp;
                </button>
                <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="xadmin.close()">
                    &emsp;返回&emsp;
                </button>
            </div>
        </div>

    </form>
</div>
<script>
    layui.use('form', function () {
        let $ = layui.$;
        var form = layui.form;
        form.render();

        $.fn.extend({
            serializeObject: function () {
                var obj = {}; //声明一个对象
                $.each(this.serializeArray(), function (index, field) {
                    obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                })
                return obj;
            }
        });


        $(function () {
            $('#saudiw img').on('click', function () {
                layer.photos({
                    photos: '#saudiw',
                    shadeClose: false,
                    closeBtn: 2,
                    anim: 0
                });
            })
        });
        form.on('submit(' + $("button[lay-submit]:eq(0)").attr("lay-filter") + ')', function (data) {
            if($("#giftid").val()===''){
                layer.msg("请选择礼物", {icon: 2, time: 1000}, function () {});
                return false;
            }


            layer.confirm('确认要保存吗？', function (index) {
                ajaxPost(layui.$, $("#formsubmit").attr("action"), $("#formsubmit").serializeObject(), function (data) {
                    if (data.code === 1) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                            xadmin.father_reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 3000}, function () {
                            xadmin.close();
                        });
                    }
                });
            });
        });
        form.on('select(vipZu)', function (data) {
            //对应lay-filter
            $("#vipZuValue").val(data.value);

            //获取value值
        });
    });

    function complaintsHandling(state) {
        var id = $("#id").val();
        var vipZ = $("#vipZuValue").val();
        if (state == 1) {
            ajaxPost(layui.$, "/authentic/audit", {
                "id": id,
                "state": state,
                "remark": ""
            }, function (data) {
                /* $.ajax({
                     type: "POST",
                     url: "/authentic/audit",
                     data: {
                         "id": id,
                         "state": state,
                         "remark": ""
                     },
                     dataType: "json",
                     success: function (data) {
                         console.log(data)*/
                if (data.code == 200) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        parent.location.reload();
                    });
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000}, function () {
                    });
                }

            });
        } else {
            layer.prompt({title: '请输入驳回原因', maxlength: 20}, function (slogisticCode, index) {
                layer.close(index);
                $("#remark").val(slogisticCode);
                 ajaxPost(layui.$, "/authentic/audit", {
                     "id": id,
                     "state": state,
                     "vip": vipZ,
                     "remark": $("#remark").val()
                 }, function (data) {
                     /* $.ajax({
                          type: "POST",
                          url: "/authentic/audit",
                          data: {
                              "id": id,
                              "state": state,
                              "vip": vipZ,
                              "remark": $("#remark").val()
                          },
                          dataType: "json",
                          success: function (data) {
                              console.log(data)*/
                     if (data.code == 200) {
                         layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                             parent.location.reload();
                         });
                     } else {
                         layer.msg(data.msg, {icon: 2, time: 1000}, function () {
                         });
                     }

                 });
            });
        }


    }

    function banned(obj, phone) {
        layui.use('layer', function () {
            let $ = layui.$;
            layer.confirm('确认要将该用户移入黑名单吗？', function (index) {
                ajaxPost(layui.$, "/user/fengting", {"idArray": phone}, function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function () {

                        });
                    }
                });
            });
        });


    }
</script>
</body>

</html>